package com.java.demo;

import java.io.File;

public class FileUtils {

    public static void main(String[] args) {
        renameFile();
//        deleteFile();
    }

    public static void renameFile() {
        int count = 50;
//        String filePath = "C:/Users/Administrator/Desktop/临时文件/me(1)/me/tab_me_";
//        String filePath = "C:/Users/Administrator/Desktop/临时文件/序列帧/community序列帧/tab_community_";
//        String filePath = "C:/Users/Administrator/Desktop/临时文件/序列帧/fun序列帧/tab_fun _";
//          String filePath = "C:/Users/Administrator/Desktop/临时文件/序列帧/hongbao序列帧/tab_hongbao_";
         String filePath = "C:/Users/Administrator/Desktop/临时文件/序列帧/home序列帧/tab_home_";
        for (int i = 0; i < count; i++) {
            if (i >= 10) {
                File oldFile = new File(filePath + i + "@2x.png");
                File newFile = new File(filePath.replace(" ", "") + "000" + i + ".png");
                if (oldFile.renameTo(newFile)) {
                    System.out.println("已重命名");
                } else {
                    System.out.println("Error");
                }
            } else {
                File oldFile = new File(filePath + i + "@2x.png");
                File newFile = new File(filePath.replace(" ", "") + "0000" + i + ".png");
                if (oldFile.renameTo(newFile)) {
                    System.out.println("已重命名");
                } else {
                    System.out.println("Error");
                }
            }
        }
    }

    public static void deleteFile() {
        int count = 50;
        String filePath = "C:/Users/Administrator/Desktop/临时文件/序列帧/fun序列帧/tab_fun _";
        for (int i = 0; i < count; i++) {
            File oldFile = new File(filePath + i + "@2x.png");
            if (oldFile.delete()) {
                System.out.println("已重命名");
            } else {
                System.out.println("Error");
            }
        }
    }
}
